package nina.yiyou.paystub

import groovy.transform.PackageScope
import nina.yiyou.paystub.input.ClipboardImageReader
import nina.yiyou.paystub.input.TableMetaReader
import nina.yiyou.paystub.output.PaystubResultGenerator
import nina.yiyou.paystub.start.PaystubArgsParser

import java.awt.Image
import java.nio.file.Files
import java.nio.file.Path

/**
 * 生成工资单图片
 */
@PackageScope
class Main {

  static void main(String[] args) {
    def paystubArg = new PaystubArgsParser(args).parse()
    Path resultExcel = paystubArg.resultExcel()
    assert Files.isRegularFile(resultExcel)

    println('读取表格图像...')
    Image tableImg = new ClipboardImageReader(resultExcel).read()

    println('读取表格信息...')
    TableMetaReader.Meta tableMeta = new TableMetaReader(resultExcel).read()

    println('生成工资单图片...')
    new PaystubResultGenerator(tableImg, tableMeta, resultExcel).generate()
  }
}
